<template>
	<view class="template-screen tn-safe-area-inset-bottom">


	
		<!-- 顶部自定义导航 -->
		<tn-nav-bar fixed alpha customBack>
			<view slot="back" class='tn-custom-nav-bar__back' @click="goBack">
				<text class='icon tn-icon-left'></text>
				<text class='icon tn-icon-home-capsule-fill'></text>
			</view>
		</tn-nav-bar>
	


		<view style="background-color: #FFF;">

			<view class="" style="margin-top: 50rpx;">
				<view class="tn-flex tn-flex-row-between">
					<view class="justify-content-item tn-margin tn-text-bold tn-text-xl">
						百科阅读
					</view>
					<view class="tn-margin" style="font-size: 50rpx;">
						<text class="tn-icon-data"></text>
					</view>
				</view>
			</view>

			<view class="tn-margin-left tn-text-sm tn-color-gray" style="margin-top: -25rpx;">
				<text>阅读文章，请查收吖</text>
			</view>


			<!-- 不建议写时间，因为写了时间，你就要经常更新文章了鸭-->
			<view class="">
				<block v-for="(item, index) in hotArticle" :key="index">
					<view class="article-shadow tn-margin" @click="tn('/pages/main/tabbar/tabbar-2/details?id=' + item.id)">
						<view class="tn-flex">
							<view class="image-pic tn-margin-sm"
								:style="'background-image:url(' + item.cover_image + ')'">
								<view class="image-article">
								</view>
							</view>
							<view class="tn-margin-sm tn-padding-top-xs" style="width: 100%;">
								<view class="tn-text-lg tn-text-bold clamp-text-1 tn-text-justify">
									{{ item.title }}
								</view>
								<view class="tn-padding-top-xs" style="min-height: 105rpx;">
									<text class="tn-text-df tn-color-gray clamp-text-2 tn-text-justify">
										{{ item.desc }}
									</text>
								</view>
								<view class="tn-flex tn-flex-row-between tn-flex-col-between">
									<view v-for="(tags_item,tags_index) in item.tags" :key="tags_index"
										class="justify-content-item tn-tag-content__item tn-margin-right tn-round tn-text-sm tn-text-bold"
										:class="[`tn-bg-${item.color}--light tn-color-${item.color}`]">
										<text class="tn-tag-content__item--prefix">#</text> {{ tags_item }}
									</view>
									<view
										class="justify-content-item tn-color-gray tn-text-center tn-color-gray--disabled"
										style="padding-top: 5rpx;">
										<text class="tn-icon-footprint tn-padding-right-xs tn-text-lg"></text>
										<text class="tn-padding-right tn-text-df">{{ item.view_count }}</text>
										<text class="tn-icon-like tn-padding-right-xs tn-text-lg"></text>
										<text class="tn-text-df">{{ item.like_count }}</text>
									</view>
								</view>
							</view>
						</view>
					</view>
				</block>
			</view>



		</view>

		
		<!-- 回到首页悬浮按钮-->
		<nav-index-button></nav-index-button>

	</view>
</template>

<script>
	import template_page_mixin from '@/libs/mixin/template_page_mixin.js'
	import NavIndexButton from '@/libs/components/nav-index-button.vue'
	import hotPage from '@/pages/main/tabbar/tabbar-2/hot.vue'
	export default {
		name: 'TemplateScreen',
		mixins: [template_page_mixin],
		components: {
			NavIndexButton,
			hotPage
		},
		data() {
			return {
				hbgcolor: '#FFF',
				banner: [],
				cardCur: 0,
				swiperList: [],			
				planList: [],
				hotArticle: []
			}
		},
		onLoad() {
		
			this.getArticleList()
		},
		methods: {
			click(e) {
				uni.navigateTo({
					url:e
				})
				// console.log(e)
			 
			},
			getArticleList() {
				// 在你的uniapp页面或组件中使用以下代码
				uni.request({
					url: 'https://xq.michuang.top/api/index/getArticleList',
					method: 'POST',
					
					success: (res) => {
						if (res.data) {
							// 成功获取数据
							// 更新轮播图数据
							this.hotArticle = res.data.data;
						} else {
							// 处理请求失败的情况
							console.error('接口请求失败');
						}
					},
					fail: (err) => {
						// 处理请求失败的情况
						console.error('接口请求失败', err);
					}
				});
			
			},
			
			// cardSwiper
			cardSwiper(e) {
			  this.cardCur = e.detail.current
			},
			// 跳转
			tn(e) {
				uni.navigateTo({
					url: e,
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	@import '@/static/css/templatePage/custom_nav_bar.scss';

	

	/* 资讯主图 start*/
	.image-article {
		border-radius: 8rpx;
		border: 1rpx solid #F8F7F8;
		width: 200rpx;
		height: 200rpx;
		position: relative;
	}

	.image-pic {
		background-size: cover;
		background-repeat: no-repeat;
		// background-attachment:fixed;
		background-position: top;
		border-radius: 10rpx;
	}

	.article-shadow {
		border-radius: 15rpx;
		box-shadow: 0rpx 0rpx 50rpx 0rpx rgba(0, 0, 0, 0.07);
	}

	/* 文字截取*/
	.clamp-text-1 {
		-webkit-line-clamp: 1;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		text-overflow: ellipsis;
		overflow: hidden;
	}

	.clamp-text-2 {
		-webkit-line-clamp: 2;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		text-overflow: ellipsis;
		overflow: hidden;
	}

	/* 标签内容 start*/
	.tn-tag-content {
		&__item {
			display: inline-block;
			line-height: 35rpx;
			padding: 5rpx 25rpx;

			&--prefix {
				padding-right: 10rpx;
			}
		}
	}

	/* 底部tabbar start*/
	.footerfixed {
		position: fixed;
		width: 100%;
		bottom: 0;
		z-index: 999;
		background-color: #FFFFFF;
		box-shadow: 0rpx 0rpx 30rpx 0rpx rgba(0, 0, 0, 0.07);
	}

	.tabbar {
		display: flex;
		align-items: center;
		min-height: 110rpx;
		justify-content: space-between;
		padding: 0;
		height: calc(110rpx + env(safe-area-inset-bottom) / 2);
		padding-bottom: calc(env(safe-area-inset-bottom) / 2);
	}

	.tabbar .action {
		font-size: 22rpx;
		position: relative;
		flex: 1;
		text-align: center;
		padding: 0;
		display: block;
		height: auto;
		line-height: 1;
		margin: 0;
		overflow: initial;
	}

	.tabbar .action .bar-icon {
		width: 100rpx;
		position: relative;
		display: block;
		height: auto;
		margin: 0 auto 10rpx;
		text-align: center;
		font-size: 42rpx;
		// line-height: 50rpx;
	}

	.tabbar .action .bar-icon image {
		width: 50rpx;
		height: 50rpx;
		display: inline-block;
	}

	.tabbar .action .bar-circle {
		position: relative;
		display: block;
		margin: -30rpx auto 20rpx;
		text-align: center;
		font-size: 52rpx;
		line-height: 90rpx;
		background-color: #FFCA28;
		width: 90rpx !important;
		height: 90rpx !important;
		overflow: hidden;
		border-radius: 50%;
		box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(255, 202, 40, 0.5);
	}

	.tabbar .action .bar-circle image {
		width: 60rpx;
		height: 60rpx;
		display: inline-block;
		margin: 15rpx auto 15rpx;
	}
</style>